import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SubstanceGeminiLookAndFeel;


import system.activity.MainWindowActivity;

public class Main 
{
	public static void setupSubstance() {
        try {
        	//необходимо для загрузки выбранного пользователем скина
            final String fileName = System.getProperty("user.home") + System.getProperty("file.separator") + "quickdoestyle.txt";
            final Properties properties = new Properties();
            org.pushingpixels.substance.api.SubstanceLookAndFeel laf = new SubstanceGeminiLookAndFeel();
            UIManager.setLookAndFeel(laf);
            UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override public void run() {
                    try {
                        String skinClassName = SubstanceLookAndFeel.getCurrentSkin().getClass().getCanonicalName();
                        properties.setProperty("skinClassName", skinClassName);
                        properties.store(new FileOutputStream(fileName), fileName);
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            });
            properties.load(new FileInputStream(fileName));
            String skinClassName = properties.getProperty("skinClassName");
            laf.setSkin(skinClassName);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
	public static void main(String[] args) {

		setupSubstance();
		MainWindowActivity activity = new MainWindowActivity();
	}
}
